var zyl_swfURLName = null;
var zyl_hosturl =XN.env.staticRoot+"xnapp/gift/flash/";
var zyl_structs='<div id="flash_zyl_structs" style="position:relative;"><div class="loading"><p>载入中...</p></div></div>';
var __flashwrap = null;
function create_flash_div(gid,swfName,asVersion) {
	if(__flashwrap == null) {
		__flashwrap = document.createElement("div");
		__flashwrap.id = "flashwrap";
		__flashwrap.className = "flashwrap";
		document.body.appendChild(__flashwrap);
	}
	$('flashwrap').show();
	__flashwrap.style.width = "510px";
	__flashwrap.style.height = "360px";
	__flashwrap.innerHTML = zyl_structs;
	$('flash_zyl_structs').innerHTML = create_flash_dialog();
	centerBox($('flashwrap'));
	btn_close();
	zyl_swfURLName = swfName;
	if(checkFlash()){
		if(arguments.length>3)
			getflash(gid,asVersion,arguments[3]);
		else
			getflash(gid,asVersion);
	}else{
		$('flashshow').className = "flash_pop";
		$('flashshow').innerHTML= '你没有安装flash插件，无法正常浏览礼物，请到<a href="http://www.adobe.com/go/EN_US-H-GET-FLASH" target="_blank" onclick="closeFlashGift();">这里下载</a>安装。[<a href="#nogo" onclick="closeFlashGift();">关闭</a>]';
	}
}
function getflash(gid,asVersion) {
	
	swfName = zyl_hosturl+ zyl_swfURLName +".swf";
	var previewflash = zyl_hosturl+"preview_as2_v0.1.swf";
	if(asVersion==3)
		previewflash = zyl_hosturl + "preview_as3_v0.5.swf";
	var xiaoneiFlash = new SWFObject(previewflash, "xiaoneiflash", "500", "350", "8", "");
	if(asVersion!=3)
		xiaoneiFlash.addParam("wmode","transparent");
	xiaoneiFlash.addParam("menu",false);
	xiaoneiFlash.addVariable("xiaoneigift",swfName);
	
	xiaoneiFlash.addParam('allowScriptAccess', 'always');
	if(arguments.length>2){
		xiaoneiFlash.addVariable("flashdata", arguments[2]);
	}
	xiaoneiFlash.addVariable("giftid",gid);
	xiaoneiFlash.write('flashshow');
}
function create_flash_dialog() {var str = "";str +='<div class="closewrapper">';str +='<div id="flashshow"></div>';str +='<div id="closeFlash" onclick="closeFlashGift();" onmousedown="closeFlashGift();"></div>';str +='</div>';return str;}
function btn_close() {
	var xiaoneiFlash = new SWFObject(zyl_hosturl+"close.swf", "xiaoneiflash_close", "75", "30", "8", "");
	xiaoneiFlash.addParam("wmode","transparent");
	xiaoneiFlash.addParam("menu",false);
	xiaoneiFlash.addParam('allowScriptAccess', 'always');
	xiaoneiFlash.write('closeFlash');
}
function closeFlashGift() {
	$('flashwrap').hide();
	setTimeout(flash_call, 300);
}
var flash_call = function() {
	$('flashwrap').innerHTML='';
}
function checkFlash(){
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	if (document.getElementById && version["major"] > 0) {
		return true;
	}else{
		return false;
	}
}
//check flash  version.Need swfobject.js
function checkFlashPlayerPlugin(ver){
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	if (document.getElementById && version["major"] < ver) {
		return false;
	}else{
		return true;
	}
}
//返回各种安装文件
function checkFlashOS(){
	var str = "你的FlashPlayer版本过低，请下载升级：";
	if(XN.browser.IE){
		return str + '<a href="'+XN.env.staticRoot+'xnapp/common/download/install_flash_player_ax.exe">下载最新插件</a>';
	}else{
		return str +'<br /><a href="'+XN.env.staticRoot+'xnapp/common/download/install_flash_player.exe" style="display:inline">Firefox(win)</a><span class="pipe">|</span><a href="'+XN.env.staticRoot+'xnapp/common/download/install_flash_player_osx_ub.dmg" style="display:inline"> Mac OS X</a><span class="pipe">|</span><a href="'+XN.env.staticRoot+'xnapp/common/download/install_flash_player_10_linux.deb" style="display:inline"> Linux(.deb)</a> ';
	}
}


/*dom元素居中*/
function centerBox(C){
    var A;
    var B;
    var E;
    var D;
    if (C.innerHeight) {
        A = C.innerWidth;
        B = C.pageXOffset;
        E = C.innerHeight;
        D = C.pageYOffset
    }
    else {
        A = document.documentElement.offsetWidth;
        B = document.documentElement.scrollLeft;
        E = document.documentElement.clientHeight;
        D = document.documentElement.scrollTop||window.pageYOffset;
    }
    C.style.left = (B + (A - C.offsetWidth) / 2) + "px";
    C.style.top = (D + (E - C.offsetHeight) / 2) + "px"
}
